package com.jacky.light;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

import java.util.Objects;

public class SceneController {

    @FXML
    private CheckBox checkBox;

    @FXML
    private ImageView imageView;

    @FXML
    private Label label;

    Image onImg = new Image(Objects.requireNonNull(getClass().getResourceAsStream("lightbulbON.png")));
    Image offImg = new Image(Objects.requireNonNull(getClass().getResourceAsStream("lightbulbOFF.png")));

    @FXML
    void change(ActionEvent event) {
        if (checkBox.isSelected()) {
            label.setText("ON");
            System.out.println("selected / ON");
            imageView.setImage(onImg);
        } else {
            label.setText("OFF");
            System.out.println("unselected / OFF");
            imageView.setImage(offImg);
        }
    }
}
